package com.eve.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder.Builder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Gateway 配置
 * @author HXL
 *
 */
@Configuration
public class GatewayConfig {

	@Bean
	public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
		Builder routes = routeLocatorBuilder.routes();
		// 百度
		routes.route("path_news",
				r->r.path("/guonei").uri("http://news.baidu.com")).build();
		routes.route("path_baidu", 
                r->r.path("/").uri("http://www.baidu.com")).build();
		
		return routes.build();
	}
}
